name = input("请输入您的姓名：")
with open('D:\\Python\\projects\\python_01\\files\\guest.txt') as file_object:
    file_object.write(name)
    print("姓名录入成功！")
with open('D:\\Python\\projects\\python_01\\files\\guest_book.txt') as file_object:
    active = True
    tips = "请输入姓名："
    tips += "\n输入 'quit' 结束。"
    while active:
        names = input(tips)
        if names != 'quit':
            message = 'Good morning!'
            file_object.write(names + "," + message+"\n")
            print("姓名录入成功！")
        else:
            break
with open('D:\\Python\\projects\\python_01\\files\\reasons.txt', 'w') as file_object:
    info_1 = "你为何喜欢编程？"
    info_2 = "还有其他原因吗？(yes/no)"
    info_3 = "还有什么："
    active = True
    reason_1 = input(info_1)
    while active:
        reasons = input(info_2)
        if reasons == 'yes':
            reason_2 = input(info_3)
            file_object.write(reason_1+"\n")
        elif reasons == 'no':
            active = False
    file_object.write(reason_2+"\n\r")
    print("原因写入成功！")
